import socket
import threading

# target_host = 'dwang.top'
target_host = '0.0.0.0'
target_ip = 9999

# 创建， 绑定， 监听
# 相当于一个公司
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((target_host, target_ip, ))
# for i in range(3):
print(client)
client.send(b"GET / HTTP/1.1\r\nHost:www.zgtxcj.com\r\n\r\n")
print("sent has finished.")
response = client.recv(4096)
print(response)

with open('111.html', 'wb') as f:
    f.write(response)

# server.bind((bind_id, bind_port))
# server.listen(5)

# print("[*] Listening on %s:%d" % (bind_id, bind_port))
#
#
# # 接受并发送
# def handle_client(client_socket):
#     request = client_socket.recv(1024)
#
#     print("[*] Received: %s" % request)
#
#     client_socket.send(b"ACK!")
#     client_socket.close()
#
#
# while True:
#     # 接听
#     # 相当于一个前台，接待人员
#     client, addr = server.accept()
#
#     print(client)
#     print(addr)
#     print("[*] Accepted connection from:%s:%d" % (addr[0], addr[1]))
#
#     client_handler = threading.Thread(target=handle_client, args=(client, ))
#     client_handler.start()
